package com.example.javabase.genericity;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @author 何昌杰
 */
public class Main1 {
    /**
     * 泛型擦除
     * @param args
     */
    public static void main(String[] args) {
        List<Integer> l1 = new ArrayList<>();
        List<String> l2 = new ArrayList<>();
        System.out.println(l1.getClass() == l2.getClass());

        ArrayList<Integer> list = new ArrayList<>();
        Object[] array = list.toArray();

        String[] ints = new String[]{"1","2","3"};
        ArrayList<String> list1 = new ArrayList<>(Arrays.asList(ints)) ;
        System.out.println(ints.length);
        System.out.println(list1.size());

        list1.add("4");
        System.out.println(list1.size());

        ArrayList< String> arrayList = new ArrayList<>(ints.length);
        Collections.addAll(arrayList, ints);
        System.out.println(arrayList.size());
    }
}
